package cn.zhuangcloud.newversion.common.interceptor;

import cn.zhuangcloud.newversion.common.kit.TokenKit;
import cn.zhuangcloud.newversion.common.model.Users;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

public class LoginInterceptor implements Interceptor {
    @Override
    public void intercept(Invocation inv) {
        Controller c = inv.getController();
        Users user = TokenKit.getUserByToken(c.getCookie(TokenKit.COOKIEID));
        if (user != null) {
            c.setAttr("user", user);
        }
        inv.invoke();
    }
}
